import random

all_finger = ["剪刀", "石头", "布"]
# 0 1 输
# 0 2 赢
# 1 2 输
#
# 1 0 赢
# 2 0 输
# 2 1 赢
user_input = input("请输入：剪刀、石头、布：")
computer = random.choice(all_finger)
while True:
    if user_input not in all_finger:
        user_input = input("输入有误，请重新输入：剪刀、石头、布：")
        continue
    if user_input == computer:
        user_input = input("平局，请重新输入：剪刀、石头、布：")
        computer = random.choice(all_finger)
    elif all_finger.index(user_input) < all_finger.index(computer) and all_finger.index(user_input) - all_finger.index(
            computer) == -2:
        print("你的是{}，电脑的是：{},你赢了".format(user_input, computer))
        break
    elif all_finger.index(user_input) > all_finger.index(computer) and all_finger.index(user_input) - all_finger.index(
            computer) < 2:
        print("你的是{}，电脑的是：{},你赢了".format(user_input, computer))
        break
    else:
        print("你的是{}，电脑的是：{},你输了".format(user_input, computer))
        break
